//
//  PinlunInputView.m
//  BigJoy
//
//  Created by Rowling on 2017/7/14.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "PinlunInputView.h"
@interface PinlunInputView()
@property (weak, nonatomic) IBOutlet UIView *PinlunView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *pinlunBottmoSpace;


@end
@implementation PinlunInputView

-(void)addobserverForKeyBorad {
    @weakify(self);
    [[NSNotificationCenter defaultCenter] addObserverForName: UIKeyboardWillChangeFrameNotification object:nil queue: [NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        CGFloat endY = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y;
        CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
        CGFloat tempY = SCREEN_HEIGHT - endY;
        @strongify(self);
            [UIView animateWithDuration:duration animations:^{
                self.pinlunBottmoSpace.constant = tempY;
                [self layoutIfNeeded];
            }];
        
    }];
}

-(void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    [self.textView becomeFirstResponder];
}

-(void)awakeFromNib {
    [super awakeFromNib];
    self.pinlunBottmoSpace.constant = 0;
    [self addobserverForKeyBorad];
}

- (IBAction)dismisButtonClick:(id)sender {
    [self removeFromSuperview];
}

-(void)dealloc {
    NSLog(@"inputViewDealloc");
}

+(instancetype)fastLogin {
    return FastLogin;
}
@end
